<template>
  <section v-loading="loading" class="feng-dian-private-data">
    <h2>我的申报信息</h2>
    <el-form
    ref="ruleFormRef"
    :model="ruleForm"
    :rules="rules"
    label-width="auto"
    :inline="true"
  >
    <el-form-item label="数据日期：" prop="certainDate">
      <el-date-picker
        v-model="ruleForm.certainDate"
        type="daterange"
        clearable
        :editable="false"
        placeholder="请选择数据日期"
        format="YYYY-MM-DD"
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
        value-format="YYYY-MM-DD"
        :disabled-date="disabledDate"
        @calendar-change="calendarChange"
      />
    </el-form-item>
    <el-form-item label="验证码：" prop="uniqueCode">
      <el-input v-model.trim="ruleForm.uniqueCode" type="password" placeholder="请输入验证码" />
    </el-form-item>
    <el-form-item>
      <el-button @click="resetForm">重置</el-button>
      <el-button type="primary" @click="submitForm">获取</el-button>
    </el-form-item>
  </el-form>
  <div class="req-history">
    <h5>获取记录(不一定成功):</h5>
    <div class="req-history__item" v-for="item in reqHistory" :key="item.certainDate + Math.random()">
      <div>数据日期：<span>{{ item.certainDate }}</span></div>
      <div>数据类型：<span>{{ item.reqTypes }}</span></div>
    </div>
  </div>
  </section>
</template>

<script lang="ts" setup>
import {ref} from 'vue'
import {usePrivateData} from '.'

const ruleFormRef = ref(null)

const {
    loading,
    ruleForm,
    rules,
    submitForm,
    resetForm,
    reqHistory,
    disabledDate,
    calendarChange
  } = usePrivateData(ruleFormRef)
</script>

<style lang="scss" scoped>
.feng-dian-private-data {
  .req-history {
    margin-top: 30px;
    &__item {
      margin-bottom: 22px
    }
  }
  :deep(.el-form) {
    .el-select {
      width: initial;
      min-width:200px;
    }
  }
}
</style>
